/*
 * @(#)InfoWindow.java     Robert Denda&Didier Gutacker
 *
 */

/** 
 *
 * @author 	Robert Denda&Didier Gutacker
 * @version     1.1, 05.09.1997
 */

/*
 * original version by Robert Denda, changes by Didier Gutacker 
 */

import java.awt.*;

public class InfoWindow extends Frame {
  Button okayButton;
  String content;
  TextArea textArea;

  /**
   *  Konstruktor fuer feste InfoWindowgroesse
   */

  public InfoWindow( String title ) {
    this.textArea = new TextArea( 20, 64 );
    textArea.setEditable( false );
    add( "Center", textArea );
    okayButton = new Button( "Okay" );
    add( "South", okayButton );
    pack();
    setTitle( title );
  } // InfoWindow.InfoWindow

   /**
   *  Konstruktor fuer variable InfoWindowgroesse
   */

  public InfoWindow( String title,int height, int width ) {
    this.textArea = new TextArea( height,width );
    textArea.setEditable( false );
    add( "Center", textArea );
    okayButton = new Button( "Okay" );
    add( "South", okayButton );
    pack();
    setTitle( title );
  } // InfoWindow.InfoWindow

  synchronized public boolean action( Event e, Object obj ) {
    if ( obj.equals( "Okay" ) ) {
      hide();
      notify();
      return true;
    } // if
    return false;
  } // InfoWindow.action
  
  synchronized public void paint( Graphics gc ) {
    if ( content != null ) {
      textArea.setText( content );
    } // if
  } // InfoWindow.paint

  synchronized public void waitForConfirmation() {
    try {
      wait();
    } catch( InterruptedException e ) {
    } // try
  } // InfoWindow.waitForConfirmation

  public void setContent( String content ) {
    this.content = content;
  } // InfoWindow.setContent

  public void expose() {
    show();
    repaint();
  } // InfoWindow.expose

  public void expose( String content ) {
    this.content = content;
    expose();
  } // InfoWindow.expose

  synchronized public void finishUp() {
    content = null;
    dispose();
  } // InfoWindow.finishUp
} // InfoWindow
